	@include('admin.head')
	<div class="container">
		<div class="row">
			@include('admin.side')
			<div class="col-md-10" id="content-wrapper" position: relative;>

				<div class="row">
					<style>
					#cover{
						width: 100%;
						height: 100%;
						position: absolute;
						top: 0;
						background: rgba(0,0,0,0.5);
						z-index: 1000;
						display: none;
					}
					</style>
					<div id="cover">
						<div class="row">
							<div class="col-xs-10">
							<div class="col-xs-6 col-xs-offset-4">
								<div class="main-box">
									<h2>添加开发区</h2>
									<form role="form" >
										<div class="form-group">
											<label for="username">开发区名称</label>
											<input type="email" class="form-control" name="company_name" placeholder="">
										</div>
										<div class="form-group">
											<label for="pass">图片</label>
											<input type="file" name="imgFile" id="image">
											<span class="fileName"></span>
											<input type="hidden" name="image">
										</div>
										<div class="form-group">
											<label for="exampleTextarea">描述</label>
											<textarea class="form-control" name="description" rows="5"></textarea>
										</div>

										<div style="margin-top:50px;"></div>
										<button type="button" class="btn btn-info" id="btn_sub"> 添 加 </button>
										<button type="button" class="btn btn-danger" id="btn_cancel"> 取 消 </button>
									</form>
								</div>



							</div>
						</div>
						</div>
					</div>




				<div class="col-xs-12">
					<div class="main-box clearfix">
						<div class="clearfix">
							<h2 class="pull-left">开发区</h2>
							<div class="filter-block pull-right">
								<button id="btn_add" class="btn btn-primary pull-right">
									<i class="fa fa-plus-circle fa-lg"></i> 添加开发区用户
								</button>
								<button style="margin-right:15px;" id="addNews" class="btn btn-primary pull-right">
									<i class="fa fa-plus-circle fa-lg"></i> 添加开发区资讯
								</button>

							</div>
						</div>
						<div class="table-responsive">
							<table class="table user-list" id="all-admins">
								<thead>
									<tr>
										<th data-column-id="id"><span>ID</span></th>
										<th data-column-id="title" data-sortable="false"><span>标题</span></th>
										<th data-column-id="description" data-formatter="description" data-sortable="false"><span>简介</span></th>
										<th data-column-id="create_time" data-sortable="false"><span>发表时间</span></th>
										<th data-column-id="type" data-formatter="type" data-sortable="false"><span>开发区</span></th>
										<th data-sortable="false" data-formatter="commands"><span>操作</span></th>
									</tr>
								</thead>
								<tbody>
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

	@include("admin.footer")
	@include("admin.common")
</body>

<<script src="<%url('js/clip/ZeroClipboard.min.js')%>"></script>
<script type="text/javascript">

var labelsSetting = {
	infos: "当前第 {{ctx.start}} 条 到 {{ctx.end}} 条 共 {{ctx.total}} 条数据",
	search: "搜索",
	loading: "正在加载...",
	noResults: "未找到您要的数据...",
	refresh: "刷新",
	all: "全部"
};
$("#all-admins").bootgrid({
	rowCount: [10, 25, 50],
    ajax:true,
    url: "development/list",
    labels:labelsSetting,
    formatters: {
    	"commands": function(k, v){
    		return '<a href="javascript:void(0);" class="table-link doEdit" nid="'+v.id+'"><span class="fa-stack"><i class="fa fa-square fa-stack-2x"></i><i class="fa fa-pencil fa-stack-1x fa-inverse"></i></span></a>' + '<a href="javascript:void(0);" class="table-link doCopy"  data-clipboard-text="' + '<%url("information/detail?nid=")%>' + v.id + '" nid="'+v.id+'"><span class="fa-stack"><i class="fa fa-square fa-stack-2x"></i><i class="fa fa-link fa-stack-1x fa-inverse"></i></span></a>' + '<a href="javascript:void(0);" class="table-link doDelete" nid="'+v.id+'"><span class="fa-stack"><i class="fa fa-square fa-stack-2x"></i><i class="fa fa-trash-o fa-stack-1x fa-inverse"></i></span></a>';
    	},
    	"description": function(k, v){
    		if(v.description.length > 20){
    			return v.description.substr(0, 19);
    		}else{
    			return v.description;
    		}
    	},
    	"type": function(k, v){
    		if(v.development){
    			return v.development.company_name;
    		}else{
    			return "开发区版块";
    		}
    	}
    }
}).on("loaded.rs.jquery.bootgrid", function (e)
    {
    	$(".doEdit").bind('click',function(){
    		var nid = $(this).attr('nid');
    		window.location.href="development/edit_news?nid="+nid;
    	})

    	$(".doDelete").bind("click", function(){
    		var nid = $(this).attr("nid");
			confirm("", "确定要删除吗?", "", function(data){
				if(data == 1){
					$.get("development/delete", {nid : nid}, function (data){
						if(data.success){
							window.location.reload();
						}
					})
				}
			})
    	});

    	var client = new ZeroClipboard( $(".doCopy") );

		client.on( "ready", function( readyEvent ) {
			client.on( "aftercopy", function( event ) {
				success("", "复制成功!");
			});
		});
    });



$("#all-admins-header").hide();


$('#btn_add').bind('click',function(){
	$('#cover').show();
})
$('#btn_cancel').bind('click',function(){
	$('#cover').hide();
})

$('#image').AjaxFileUpload({
	path : "<%url('admin/upload')%>",
	onComplete : function(filename){
			$(this).siblings('input[name="image"]').val(filename.filename);
			$(this).siblings('span[class="fileName"]').html(filename.filename);
		}
	});

$("#btn_sub").click(function(){
	var company_name = $("input[name='company_name']").val().trim();
	var description = $("textarea[name='description']").val().trim();
	var image = $("input[name='image']").val().trim();

	if(company_name == ''){
		warning("", "请输入开发区名称");
		return;
	}
	$.post("development/add_user", {
		company_name : company_name,
		description : description,
		image : image
	}, function (data){
		success("", "添加成功");
		setTimeout(function(){
			window.location.reload();
		}, 2000)
	})
})

$("#addNews").click(function(){
	window.location.href="development/add_news"
})



</script>


</html>